package com.arron.DesignMode.prototype;

/**
 * @Classname Client
 * @Date 2020/11/6 10:44
 * @Created by 刘
 */
public class Client {

    public static void main(String[] args) {

        System.out.println("使用原型模式创建相同对象");
        Sheep sheep = new Sheep("tom1", 12, "红色");
        Sheep sheep1 = sheep.clone();
        Sheep sheep2 = sheep.clone();
        Sheep sheep3 = sheep.clone();
        Sheep sheep4 = sheep.clone();

        System.out.println(sheep1);
        System.out.println(sheep2);
        System.out.println(sheep3);
        System.out.println(sheep4);

        System.out.println("-=======================================-");

        //缺点：不易扩展，维护，假设sheep类增加了属性，则有需要重新改进代码
        System.out.println("使用平常普通方法");

        Sheep sheep5 = new Sheep(sheep.getName(), sheep.getAge(), sheep.getColor());
        Sheep sheep6 = new Sheep(sheep.getName(), sheep.getAge(), sheep.getColor());
        Sheep sheep7 = new Sheep(sheep.getName(), sheep.getAge(), sheep.getColor());
        Sheep sheep8 = new Sheep(sheep.getName(), sheep.getAge(), sheep.getColor());


        System.out.println(sheep5);
        System.out.println(sheep6);
        System.out.println(sheep7);
        System.out.println(sheep8);



    }

}
